extends Talent

const Shop = globalData.infoDs["g_ZHPShop"]
const base = globalData.infoDs["g_ZHPBase"]
var TalentsData = preload("./talentsData.gd").getCharaData()
var ZHPLines = preload("./linesData.gd").getLinesData()
var todo = [ZHPLines.Todo_1,ZHPLines.Todo_2,ZHPLines.Todo_3,ZHPLines.Todo_4]
var thing = [ZHPLines.Thing_1,ZHPLines.Thing_2]
var x = 0

func _init():
	._init()

func init():
	name = TalentsData.NAME

func _connect():
	sys.main.connect("onBattleEnd",self,"BattleEnd")
	if base.setting.get("zhp") == true:
		Shop.PointsRate = 0.2
		Shop.CostReduction = 0.8
		Shop.saveAndLoad("save")
	else:
		sys.main.connect("onCharaDel",self,"CharaDel")
	
func get_info():
	if base.setting.get("zhp") == true:
		return TalentsData.INFO_TEXT
	else:
		return TalentsData.INFO_TEXT2

func BattleEnd():
	todo.shuffle()
	if sys.rndPer(10):
		x = 0
		sys.main.player.addItem(sys.newItem(Shop.getRndItem()))
		if base.setting.get("zhp") == true:
			if sys.rndPer(10):
				x = 1
				sys.main.player.addItem(sys.newItem("i_Hide-ZHP-Exchange"))
		sys.newBaseMsg("","{todo}{thing}".format({"todo":sys.rndListItem(todo),"thing":thing[x]}))
		

func CharaDel(cha):
	if cha.isDeath == true and cha.team != 1 and !cha.isSumm:
		sys.main.player.plusGold(3)
		sys.main.player.plusEmp(5)